#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<string.h>
#include<error.h>
#include<fcntl.h>
#include<unistd.h>
#define _PATH_ "./.tmp_fifo"

int main()
{
	umask(0);
	if(mkfifo(_PATH_,0666|S_IFIFO)<0)
	{
		perror("mkfifo");
	}
	char my_buf[1024];
	memset(my_buf,'\0',sizeof(my_buf));
		int fd=open(_PATH_,O_WRONLY);
		
			if(fd<0)
			{
					perror("open");
			}
		
	while(1)
	{
		printf("please write:");
		fflush(stdout);
		fgets(my_buf,sizeof(my_buf)-1,stdin);
		int size=write(fd,my_buf,strlen(my_buf));
	if(size<0)
	{
		printf("write error!\n");
		break;
	}
	if(strncmp(my_buf,"quit",4)==0)
	{
		break;
	}
	}
	close(fd);	
	return 0;
}
